package coda;
public class Coda {
    private int[] coda;
    private int last;

    public Coda(){
        this.coda= new int[100];
        this.last=0;
    }

    public Coda(int pDimension){
        this.coda= new int[pDimension];
        this.last=0;
    }

    public void push(int pNum){
        this.coda[this.last]=pNum;
        this.last++;
    }

    public int pop(){
        int retval=this.coda[0];
        for(int i=0; i<this.coda.length; i++){
            if(i+1==this.coda.length){
                this.coda[i-1]=this.coda[i];
                this.coda[i]=0;
            }else{
                this.coda[i]=this.coda[i+1];
            }
        }
        this.last--;
        return retval;
    }

    public int[] toArray(){
        return this.coda;
    }
}
